<template>
  <el-select :value="val" filterable :placeholder="placeholderStr" @change="changeValue">
    <el-option
      v-for="item in options"
      :key="item.key"
      :label="item.value"
      :value="item.key">
    </el-option>
  </el-select>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: "SearchSelect",
    components: { request},
    props:['addr','placeholderStr','params','val'],
    data(){
      return {options:[{}]}
    },
    model:{
      prop: 'val',
      event: 'retVal'
    },
    created(){
      request({
        url :this.$props.addr,
        params :this.$props.params,
        method: 'get'
      }).then(response => {
        this.options=response;
      });
    },
    methods:{
      changeValue(v) {
        this.value=v;
        this.$emit('retVal',v);
      }
    }
  }
</script>
